package com.pearadmin.pro.modules.mkt.rest;

import com.pearadmin.pro.modules.mkt.domain.MktContractDetail;
import com.pearadmin.pro.common.aop.annotation.Log;
import com.pearadmin.pro.common.constant.ControllerConstant;
import com.pearadmin.pro.common.web.base.BaseController;
import com.pearadmin.pro.common.web.domain.Result;
import  com.pearadmin.pro.modules.mkt.domain.MktContractDetail;
import  com.pearadmin.pro.modules.mkt.param.MktContractDetailRequest;
import  com.pearadmin.pro.modules.mkt.service.MktContractDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 市场活动合同明细Controller
 *
 * @author chenJian
 * @date 2021-09-09
 */
@Api(tags = {"市场活动合同明细"})
@RestController
@RequestMapping(ControllerConstant.ADMIN+"mkt/mktContractDetail")
public class MktContractDetailController extends BaseController
{
    @Resource
    private MktContractDetailService mktContractDetailService;

    /**
     * 查询市场活动合同明细列表
     *  @param request 查询参数
     *  @return {@link Result}
     */
    @GetMapping("/page")
    @Log(title = "市场活动合同明细列表")
    @ApiOperation(value = "市场活动合同明细列表")
    public Result<MktContractDetail> list(MktContractDetailRequest mktContractDetailRequest)
    {
        return success(mktContractDetailService.page(mktContractDetailRequest));
    }


    /**
     * 新增保存市场活动合同明细
     * @param mktContractDetail 查询参数
     * @return {@link Result}
     */
    @PostMapping("/save")
    @Log(title = "新增市场活动合同明细")
    @ApiOperation(value = "新增市场活动合同明细")
    public Result save(@RequestBody MktContractDetail mktContractDetail)
    {
        return auto(mktContractDetailService.saveOrUpdate(mktContractDetail));
    }

    /**
     * 查询市场活动合同明细详情
     *
     * @param id 市场活动合同明细ID
     * @return 市场活动合同明细
     */
    @GetMapping("/selectById")
    @Log(title = "查询市场活动合同明细详情")
    @ApiOperation(value = "查询市场活动合同明细详情")
    public Result<MktContractDetail> selectById(@RequestParam Long id)
    {
        return success(mktContractDetailService.selectMktContractDetailById(id));
    }



    /**
     * 修改保存市场活动合同明细
     * @param mktContractDetail 查询参数
     * @return {@link Result}
     */
    @PutMapping("/update")
    @Log(title = "修改市场活动合同明细")
    @ApiOperation(value = "修改市场活动合同明细")
    public Result update(@RequestBody MktContractDetail mktContractDetail)
    {
        return auto(mktContractDetailService.saveOrUpdate(mktContractDetail));
    }


    /**
     * 删除保存市场活动合同明细
     * @param id 查询参数
     * @return {@link Result}
     */
    @DeleteMapping("/remove")
    @Log(title = "删除市场活动合同明细")
    @ApiOperation(value = "删除市场活动合同明细")
    public Result remove(@RequestParam Long id)
    {
        return auto(mktContractDetailService.removeById(id));
    }

    /**
    * 批量删除市场活动合同明细
    * @param ids 批量删除
    * @return {@link Result}
    */
    @DeleteMapping("removeBatch")
    @Log(title = "批量删除市场活动合同明细")
    @ApiOperation(value = "批量删除市场活动合同明细")
    public Result removeBatch(@RequestParam List<Long> ids){
        return auto(mktContractDetailService.removeByIds(ids));
    }

}
